package com.yic.module.system.dal.mysql.appversion;

import java.util.*;

import com.yic.framework.common.pojo.PageResult;
import com.yic.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yic.framework.mybatis.core.mapper.BaseMapperX;
import com.yic.module.system.dal.dataobject.appversion.AppVersionDO;
import org.apache.ibatis.annotations.Mapper;
import com.yic.module.system.controller.admin.appversion.vo.*;

/**
 * app版本更新 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface AppVersionMapper extends BaseMapperX<AppVersionDO> {

    default PageResult<AppVersionDO> selectPage(AppVersionPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AppVersionDO>()
                .eqIfPresent(AppVersionDO::getCategory, reqVO.getCategory())
                .eqIfPresent(AppVersionDO::getVersionCode, reqVO.getVersionCode())
                .likeIfPresent(AppVersionDO::getVersionName, reqVO.getVersionName())
                .eqIfPresent(AppVersionDO::getVersionInfo, reqVO.getVersionInfo())
                .eqIfPresent(AppVersionDO::getUpdateType, reqVO.getUpdateType())
                .eqIfPresent(AppVersionDO::getAndroidUrl, reqVO.getAndroidUrl())
                .eqIfPresent(AppVersionDO::getIosUrl, reqVO.getIosUrl())
                .betweenIfPresent(AppVersionDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AppVersionDO::getId));
    }

    default List<AppVersionDO> selectList(AppVersionExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<AppVersionDO>()
                .eqIfPresent(AppVersionDO::getCategory, reqVO.getCategory())
                .eqIfPresent(AppVersionDO::getVersionCode, reqVO.getVersionCode())
                .likeIfPresent(AppVersionDO::getVersionName, reqVO.getVersionName())
                .eqIfPresent(AppVersionDO::getVersionInfo, reqVO.getVersionInfo())
                .eqIfPresent(AppVersionDO::getUpdateType, reqVO.getUpdateType())
                .eqIfPresent(AppVersionDO::getAndroidUrl, reqVO.getAndroidUrl())
                .eqIfPresent(AppVersionDO::getIosUrl, reqVO.getIosUrl())
                .betweenIfPresent(AppVersionDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AppVersionDO::getId));
    }

    default List<AppVersionDO> selectList(Integer category) {
        return selectList(new LambdaQueryWrapperX<AppVersionDO>()
                .eqIfPresent(AppVersionDO::getCategory, category));
    }
}
